
;(function(window, document){
	var Stack = function(pIntSize){
		this._maxSize = pIntSize;
		this._datas = [];
		this._topIdx = -1;
	};
	Stack.prototype = {
		constructor: Stack,
		push: function(pData){
			if( this.isFull() ){
				throw new RangeError('栈溢出');
			}
			this._datas[++this._topIdx] = pData;
		},
		pop: function(){
			if( this.isEmpty() ){
				throw new RangeError('空栈');
			}
			var value = this._datas[this._topIdx];
			this._datas.length = this._topIdx;
			this._topIdx--;
			return value;
		},
		peek: function(){
			return this._datas[this._topIdx];
		},
		isEmpty: function(){
			return this._topIdx == -1;
		},
		isFull: function(){
			return this._topIdx+1 == this._maxSize;
		},
		toString: function(){
			return '['+this._datas.join(', ')+']';
		}
	};
	window.Stack = Stack;
})(window, document);